package edu.sctu.zhu.dao;

import edu.sctu.zhu.bean.Collection;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by zhu on 2015/1/30.
 */
@Repository
@Transactional
public interface CollectionDao extends CrudRepository<Collection,Long>{
    @Query(value = " select * from collection where collection.goods_id=? And collection.fans_id=?",nativeQuery = true)
    public Collection findByGoodsAndFans(Long goods,Long fans);

    @Modifying(clearAutomatically = true)
    @Query(value = " insert INTO collection (goods_id,fans_id) VALUES(?,?) ",nativeQuery = true)
    public void insertCollection(Long goods,Long fans);
}
